<template>
  <div id="" class="replyButtom">
    <img src="@/assets/playcircleImage/comment1.png" alt="" width="20" @click="pushContent">
    <input type="text" name="" v-model="content" :placeholder="replyTip" @keyup.enter="pushContent">
  </div>
</template>
<script>
import {circleArticleCommentPush} from '@/utils/ajaxRequest.js';
export default {
  name: "",
  props: ['replyTip','articleId','replyId'],
  data: () => ({
    content:'',
    token:'',
  }),
  methods: {
    pushContent() {
      let self = this;
      let content = this.content;
      let parentId = this.replyId || '';
      console.log(parentId);
      if(content=='') {
        self.toast('请输入评论内容');
        return false;
      }
      let contentParam = {
        articleId:self.articleId,
        content:content,
        token: self.token,
        parent:parentId,      //上级回复 默认 不传
      }
      circleArticleCommentPush(contentParam).then(res=>{
        console.log(res);
        if(res) {
          self.messageBox.alert(res.data.msg).then(action=>{
            if (parentId!='') {
              self.$router.go(-1);
            }else{
              self.$router.go(0);
            }
          });
        }
      });
    }
  },
  mounted() {
    //do something after mounting vue instance
    let xlyd_loginInfo = JSON.parse(window.localStorage.getItem('xlyd_loginInfo'));
    this.token = xlyd_loginInfo.token;
  }
}
</script>
<style lang="scss" scoped>
.replyButtom{
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 333;
  padding: 12px 10px;
  border-top: 1px solid $borderColor;
  background: $boxBgcolor;
  @include flex;
  input{
    @include flexcell;
    margin-left: 10px;
    height: 30px;
    border: none;
    outline: none;
    background: none;

  }
}
</style>
